#ifndef YHAIDA_EVENTLOOPTHREAD_H
#define YHAIDA_EVENTLOOPTHREAD_H
#include "../base/Utils.h"
#include "../thread/Thread.h"
#include "../mutex/MutexLock.h"
#include "../mutex/Condition.h"
#include "EventLoop.h"
namespace yhaida
{
    class EventLoopThread : Utils::nocapyable
    {
    public:
    typedef std::function<void(EventLoop *)> ThreadInitCallback;
    public:
        EventLoopThread(const ThreadInitCallback &cb = ThreadInitCallback());
        ~EventLoopThread();

        EventLoop* startLoop();
    private:
        void threadFunc();
        EventLoop* _mainEventLoop;
        bool _isStop;
        
        MutexLock _mutex;
        Condition _cv;
        Thread _threadOFEventLoop;

        ThreadInitCallback _callback;
    };

}

#endif